473,441 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

nowrap floating divs and horizontal scroll

dlite922
1,584 Expert 1GB
This is just barely above my head when it comes to css.

I have a div that needs to contain rows of floating divs, but I need each row not to wrap on to the next one and continue to go right. The user will use a overflow: auto scroll to scroll to see the rest of the divs.

illustration:

# = === = = === ===
# = == = =
# == ==================
# =========

if an "=" is a floating fixed-height div, how do I make it so it doesn't wrap when it is longer than the parent?

This is for a similar app as a TV guide you see on your cable/sat tv.

The channels remain on the right, but you can "scroll" horizontally to see what's playing later on in the day. You only see 2 hours at a time, but you can scroll to see the full 24 hours if you wanted to.

Here's what my css

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. .eventCont {
  4.     position: relative;
  5.     width: 820px;
  6.     height: 600px;
  7.     overflow-x: auto;
  8.     overflow-y: hidden;
  9. }
  10.  
  11.  
  12. .event {    
  13.     position: relative;
  14.     float: left;
  15.     width: 200px;
  16.     height: 74px;
  17.     overflow: hidden;
  18.     border-left: 2px solid white;
  19.     border-bottom: 1px solid white;    
  20. }
  21.  
  22.  
  23.  
.eventContainer is the parent div and .event is the floating divs.

I've tried many things among:

white-space: nowrap; display + float + position combinations etc. with
no-avail.

The difficult part is, they all have to be in the same div so that there's only one scroll bar, otherwise I could put each row in a <td>.

Thanks,





Dan
Feb 24 '09 #1
4 32572
drhowarddrfine
7,435 Expert 4TB
Hmm. Never tried this but I've seen some sites with horizontal sites. I'll have to look them up. Tried a couple things that didn't work. The only thing that limits this is the body so setting the body to something like 2000px width will do it but it would be nice if you didn't have to set a width.

I'll have to think about this but I hate to think.
Feb 24 '09 #2
dlite922
1,584 Expert 1GB
@drhowarddrfine
I don't mind the body being that wide, but how did you get that to work? I set the body tag to 2000 and it didn't affect it. Reason I think it doesn't is because the parent div is a fixed length, e.g. 500px.

can you post your code?

here's mine:

Expand|Select|Wrap|Line Numbers
  1.  
  2. #parent {
  3.     overflow: auto; 
  4.     width: 500px; 
  5.     border: 1px solid red;
  6. }
  7.  
  8. .child {
  9.     float: left; 
  10.     width: 100px; 
  11.     border: 1px solid green;
  12. }
  13. </style> 
  14.  
  15.  
  16. <div id="parent">
  17.     <div class="child">Test</div>
  18.     <div class="child">Test</div>
  19.     <div class="child">Test</div>
  20.     <div class="child">Test</div>
  21.     <div class="child">Test</div>
  22.     <div class="child">Test</div>
  23.     <div class="child">Test</div>
  24. </div>
  25.  
  26.  
Sorry to hurt your brain :D



Dan
Feb 24 '09 #3
dlite922
1,584 Expert 1GB
RESOLVED

Don't hurt yourself Dr H, I solved it.

if you have 2 divs (grandParent, parent) within eachother and you have the fixed length floating divs (children) inside the parent you can accomplish a horizontal scroll if you have set the parent to a longer width than the grandParent. The children can float inside the parent without knowing the shorter width of the outter/grandParent div.

if that confused you, here's the code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <style>
  3. #grandParent {
  4.  
  5.     overflow: auto; 
  6.     width: 500px; 
  7.     height: 50px;
  8.     border: 1px solid red;
  9. }
  10.  
  11. #parent{
  12.     width: 2000px;   /* <-- this makes the grandparent have a horz scroll */
  13.     border: 2px solid green;
  14. }
  15.  
  16. .child {
  17.     width: 100px;
  18.     float: left;
  19.     border: 2px solid blue; 
  20. }
  21. </style> 
  22.  
  23.  
  24. <div id="grandParent ">
  25.     <div id="parent">
  26.         <div class="child">Event</div>
  27.         <div class="child">Event</div>
  28.         <div class="child">Event</div>
  29.         <div class="child">Event</div>
  30.         <div class="child">Event</div>
  31.     </div>
  32. </div>
  33.  
  34.  
Feb 25 '09 #4
dlite922
1,584 Expert 1GB
By the way, if anyone else is looking for other solutions there's two other things you can do.

1. IFRAME (blegh!)
2. Let the Browser window have horz on a wide <body> (width="5000px"); This is what the Dr. ordered in the second post above.

Thought I might add that,




Dan
Feb 25 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Nishant | last post by:
I have a combo box with a horizontal scroll bar. (Used SetHorizontalExtent) The dropdown with horizontal scroll bar works fine when I have more items in the dropdown list. However when the...
12
by: meltedown | last post by:
I would like the floating divs to float and then the header to come after them , on the left. That's what I thought clearing the floats was for, but in this example, the header is to the right of...
2
by: Boaz Ben-Porat | last post by:
Hi all Is there a way to simulate a click on a scrollbar (horizontal) of a FataGrid ? I need to programmatically scroll the grid to the right/left upon some condition, when the total width of...
2
by: Tina | last post by:
Am I missing something or does the listbox web control not have a horizontal scroll capability? Thanks, T
1
by: RJN | last post by:
Hi I'm using an iFrame to enclose another document. The iFrame width is sufficient to hold the enclosed document. When the enclosed document has more data and exceeds the height set for iFrame,...
3
by: Vidds | last post by:
Hi Everyone, How come Server listbox control does not have a Horizontal Scroll Property? If any one has an idea how we add a Horizontal scroll to a listbox or dropdown list box it would be quite...
1
by: amuven | last post by:
Hi All, I need to put a horizontal scroll bar for 4 cells alone where my first cell in table should not contain any horizontal scroll bar . In clear, let us say there are 5 columns in my...
1
by: newbie009 | last post by:
How can I disable horizontal scroll in textbox for FireFox? Right now 1 textbox has vertical scroll and other textbox has horizontal scroll. It only looks like this on FireFox but it looks ugly....
0
by: shanteshk | last post by:
Hi I have developed ab application in which I fecing an Issue when I browse in Google chrome i.e The Horizontal scroll bar in not appearing in an application when applicatin page size gets wider...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.